﻿<%@ Page Title="" Language="C#" MasterPageFile="~/resumemanager/resume.master" %>
<%@ Import Namespace="TalentPools.Model" %>
<%@ Import Namespace="TalentPools.BLL" %>
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["userid"]==null)
            {
                Response.Redirect("~/Default.aspx");
            }
            string resumeId = Request.QueryString["resumeId"];
            ViewState["resumeId"] = resumeId;
            if (resumeId==null || resumeId=="")
            {
                Response.Redirect("~/Default.aspx");
            }

            ddlWorkYear.DataSource = new baseConfigManager().getconfigInfo("工作时间");
            ddlWorkYear.DataTextField = "value";
            ddlWorkYear.DataValueField = "key";
            ddlWorkYear.DataBind();

            ddlMarState.DataSource = new baseConfigManager().getconfigInfo("婚姻状态");
            ddlMarState.DataTextField = "value";
            ddlMarState.DataValueField = "key";
            ddlMarState.DataBind();

            ddlpoli.DataSource = new baseConfigManager().getconfigInfo("政治面貌");
            ddlpoli.DataTextField = "value";
            ddlpoli.DataValueField = "key";
            ddlpoli.DataBind();
            
            List<resume> list = new alertResumeManager().GetResumeId(resumeId);
            if (list.Count==1)
            {
                resume r = list[0];
                txtname.Text = r.name;
                if (r.sex=="男")
                {
                    rbnan.Checked=true;
                }
                else
                {
                    rbnv.Checked = true;
                }
                txtbir.Text = r.birthday.ToShortDateString() ;
                ddlWorkYear.SelectedItem.Value = r.workYear.ToString();
                ddlMarState.SelectedItem.Value = r.marriage.ToString();
                txtcard.Text = r.card;
                ddlpoli.SelectedItem.Value = r.politicsStatus.ToString();
                txtpalce.Text = r.HKPlace;
                txtcity.Text = r.city;
                txtaddre.Text = r.currentAddress;
                txtcode.Text = r.zipCode;
                txtmobile.Text = r.cellphone;
                txtphone.Text = r.phoneCode;
                txtemail.Text = r.email;
                txtindex.Text = r.homePage;
            }
        }
    }

    protected void ibtnSubmit_Click(object sender, ImageClickEventArgs e)
    {
        if (IsValid == true)
        {
            //构造简历对象
            resume resume = new resume();
            resume.Id = ViewState["resumeId"].ToString();
            resume.userId = Session["userid"].ToString();
            resume.name = txtname.Text.Trim();
            resume.sex = rbnan.Checked ? "男" : "女";
            resume.birthday = Convert.ToDateTime(txtbir.Text.Trim());
            resume.marriage =ddlMarState.SelectedValue.ToString();
            resume.card = txtcard.Text.Trim();
            resume.politicsStatus = ddlpoli.SelectedValue.ToString();
            resume.HKPlace = txtpalce.Text.Trim();
            resume.city = txtcity.Text.Trim();
            resume.currentAddress = txtaddre.Text.Trim();
            resume.zipCode = txtcode.Text.Trim();
            resume.cellphone = txtmobile.Text.Trim();
            resume.phoneCode = txtphone.Text.Trim();
            resume.email = txtemail.Text.Trim();
            resume.homePage = txtindex.Text.Trim();
            resume.workYear = ddlWorkYear.SelectedValue.ToString();
            resume.lastUpdateTime = DateTime.Now;
            if (new alertResumeManager().updatResumeByid(resume))
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(string),"","alert('修改成功！')");
                Response.Redirect("Default.aspx");
            }
        }
    }
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table class="tableMain">
                <tr>
                    <td class="titleStyle">
                        姓名:
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtname" runat="server" Style="margin-left: 0px" ValidationGroup="first"
                            BorderStyle="None" MaxLength="20" Width="195px"></asp:TextBox>
                    </td>
                    <td class="valStyle" style="width: 97px">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ControlToValidate="txtname"
                            ErrorMessage="*必填" Display="Dynamic" ValidationGroup="first"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        性别:
                    </td>
                    <td class="textStyle">
                        <asp:RadioButton ID="rbnan" Text="男" GroupName="sex" Checked="true" runat="server" />
                        <asp:RadioButton ID="rbnv" Text="女" GroupName="sex" runat="server" />
                    </td>
                    <td class="valStyle">
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        出生日期:
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtbir" runat="server" ForeColor="#999966" ValidationGroup="first"
                            BorderStyle="None" Width="195px">格式为&quot;2010-2-1&quot;</asp:TextBox>
                    </td>
                    <td class="valStyle">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        工作时间：
                    </td>
                    <td class="textStyle">
                        <asp:DropDownList ID="ddlWorkYear" runat="server" Width="100px">
                        </asp:DropDownList>
                    </td>
                    <td class="valStyle">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        婚姻状态:
                    </td>
                    <td class="textStyle">
                        <asp:DropDownList ID="ddlMarState" runat="server" Width="195px">
                        </asp:DropDownList>
                    </td>
                    <td class="valStyle">
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        身份证号：
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtcard" runat="server" ValidationGroup="first" BorderStyle="None"
                            Width="195px"></asp:TextBox>
                    </td>
                    <td class="valStyle">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtcard"
                            ErrorMessage="*必填" Font-Size="12px" Display="Dynamic" ValidationGroup="first"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtcard"
                            Display="Dynamic" ErrorMessage="格式错误" Font-Size="12px" ValidationExpression="\d{17}[\d|X]|\d{15}"
                            ValidationGroup="first"></asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        政治面貌：
                    </td>
                    <td class="textStyle">
                        <asp:DropDownList ID="ddlpoli" runat="server" Width="195px">
                        </asp:DropDownList>
                    </td>
                    <td class="valStyle">
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        户口所在地：
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtpalce" runat="server" ValidationGroup="first" BorderStyle="None"
                            Width="195px"></asp:TextBox>
                    </td>
                    <td class="valStyle">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        现居住城市：
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtcity" runat="server" ValidationGroup="first" BorderStyle="None"
                            Width="195px"></asp:TextBox>
                    </td>
                    <td class="valStyle">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        通信地址：
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtaddre" runat="server" ValidationGroup="first" BorderStyle="None"
                            Width="195px"></asp:TextBox>
                    </td>
                    <td class="valStyle">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        邮政编码：
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtcode" runat="server" ValidationGroup="first" BorderStyle="None"
                            Width="195px"></asp:TextBox>
                    </td>
                    <td class="valStyle">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        手机：
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtmobile" runat="server" ValidationGroup="first" BorderStyle="None"
                            Width="195px"></asp:TextBox>
                    </td>
                    <td class="valStyle">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        电话：
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtphone" runat="server" BorderStyle="None" Width="195px"></asp:TextBox>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        电子邮件：
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtemail" runat="server" ValidationGroup="first" BorderStyle="None"
                            Width="195px"></asp:TextBox>
                    </td>
                    <td class="valStyle">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="titleStyle">
                        个人主页：
                    </td>
                    <td class="textStyle">
                        <asp:TextBox ID="txtindex" runat="server" BorderStyle="None" Width="195px" Wrap="False"></asp:TextBox>
                    </td>
                    <td class="valStyle">
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <asp:ImageButton ID="ibtnSubmit" runat="server" ImageUrl="~/img/create.gif" 
                            onclick="ibtnSubmit_Click" />
                    </td>
                </tr>
            </table>
</asp:Content>

